﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace SelfService.DataAccess.Migrations
{
    public partial class 修复错误 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SysCardType_SysClients_SysClientID",
                table: "SysCardType");

            migrationBuilder.DropForeignKey(
                name: "FK_SysPayType_SysClients_SysClientID",
                table: "SysPayType");

            migrationBuilder.DropIndex(
                name: "IX_SysPayType_SysClientID",
                table: "SysPayType");

            migrationBuilder.DropIndex(
                name: "IX_SysCardType_SysClientID",
                table: "SysCardType");

            migrationBuilder.DropColumn(
                name: "SysClientID",
                table: "SysPayType");

            migrationBuilder.DropColumn(
                name: "SysClientID",
                table: "SysCardType");

            migrationBuilder.CreateTable(
                name: "ClientCardType",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    ClientId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    CardTypeId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    CreateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    UpdateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ClientCardType", x => x.ID);
                    table.ForeignKey(
                        name: "FK_ClientCardType_SysCardType_CardTypeId",
                        column: x => x.CardTypeId,
                        principalTable: "SysCardType",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ClientCardType_SysClients_ClientId",
                        column: x => x.ClientId,
                        principalTable: "SysClients",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "ClientPayTypes",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    ClientId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    PayTypeId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    CreateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    UpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    UpdateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ClientPayTypes", x => x.ID);
                    table.ForeignKey(
                        name: "FK_ClientPayTypes_SysClients_ClientId",
                        column: x => x.ClientId,
                        principalTable: "SysClients",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_ClientPayTypes_SysPayType_PayTypeId",
                        column: x => x.PayTypeId,
                        principalTable: "SysPayType",
                        principalColumn: "ID",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_ClientCardType_CardTypeId",
                table: "ClientCardType",
                column: "CardTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_ClientCardType_ClientId",
                table: "ClientCardType",
                column: "ClientId");

            migrationBuilder.CreateIndex(
                name: "IX_ClientPayTypes_ClientId",
                table: "ClientPayTypes",
                column: "ClientId");

            migrationBuilder.CreateIndex(
                name: "IX_ClientPayTypes_PayTypeId",
                table: "ClientPayTypes",
                column: "PayTypeId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "ClientCardType");

            migrationBuilder.DropTable(
                name: "ClientPayTypes");

            migrationBuilder.AddColumn<Guid>(
                name: "SysClientID",
                table: "SysPayType",
                type: "char(36)",
                nullable: true,
                collation: "ascii_general_ci");

            migrationBuilder.AddColumn<Guid>(
                name: "SysClientID",
                table: "SysCardType",
                type: "char(36)",
                nullable: true,
                collation: "ascii_general_ci");

            migrationBuilder.CreateIndex(
                name: "IX_SysPayType_SysClientID",
                table: "SysPayType",
                column: "SysClientID");

            migrationBuilder.CreateIndex(
                name: "IX_SysCardType_SysClientID",
                table: "SysCardType",
                column: "SysClientID");

            migrationBuilder.AddForeignKey(
                name: "FK_SysCardType_SysClients_SysClientID",
                table: "SysCardType",
                column: "SysClientID",
                principalTable: "SysClients",
                principalColumn: "ID");

            migrationBuilder.AddForeignKey(
                name: "FK_SysPayType_SysClients_SysClientID",
                table: "SysPayType",
                column: "SysClientID",
                principalTable: "SysClients",
                principalColumn: "ID");
        }
    }
}
